function recognition(cidSublevel, lesson){
	//context.drawImage(video, 100, 40, 440, 440, 0, 0, 320, 240); 拉伸版
  	//image = context.getImageData(0, 0, 320, 240);
	context.drawImage(video, 0, 0, 640, 480, 0, 0, 320, 240);
  	var dataURL = canvas.toDataURL('images/png');
    var imageDataB64 = dataURL.substring(22);
	
	$.ajax(
		{
			type:"post",
			url:"record/recognition.action",
			dataType:"json",
			data:{
				testImage: imageDataB64,
				cidSublevel: cidSublevel,
				lesson: lesson
			},
			success:function(result){
				if(result.code == 0){
					layer.msg(result.msg);
					setTrackerState(3);
				} else if(result.code == 1){
					tableIns.reload();
					layer.msg(result.msg);
					setTrackerState(2);
				} else if(result.code == 2){
					layer.msg(result.msg);
					setTrackerState(4);
				} else if(result.code == 3){
					layer.msg(result.msg);
					setTrackerState(3);
				}
				
		    }
		});
}

function setTrackerState(trackerState) {
	var string;
	var color;
	switch (trackerState) {
	case 0:
		string = "待机中";
		color = "#333";
		break;
	case 1:
		string = "提交数据中";
		color = "#FFD934";
		break;
	case 2:
		string = "已记录";
		color = "#42B274";
		var t=setTimeout("setTrackerState(0)",2000);
		break;
	case 3:
		string = "失败，请重试！";
		color = "#FF5E5E";
		var t=setTimeout("setTrackerState(0)",2000);
		break;
	case 4:
		string = "你已签到过了！";
		color = "#FF5E5E";
		var t=setTimeout("setTrackerState(0)",2000);
		break;
	case 5:
		string = "距离太远，请靠近";
		color = "#333";
		break;
	default:
		break;
	}
	$("#trackerState").text(string).css("color", color);
}